R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

Including Plots

You can also embed plots, for example:

## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
##                id   n      prop
## 1 Females_Grouped 200 0.1680672
## 2   Females_Mated 190 0.1596639
## 3 Females_Singles 200 0.1680672
## 4   Males_Grouped 200 0.1680672
## 5     Males_Mated 200 0.1680672
## 6   Males_Singels 200 0.1680672
## Warning: package 'readr' was built under R version 4.1.3
## Warning: package 'Rtsne' was built under R version 4.1.3

## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 20.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.15 seconds (sparsity = 0.072217)!
## Learning embedding...
## Iteration 50: error is 74.609042 (50 iterations in 0.12 seconds)
## Iteration 100: error is 67.234096 (50 iterations in 0.09 seconds)
## Iteration 150: error is 66.872623 (50 iterations in 0.09 seconds)
## Iteration 200: error is 66.797404 (50 iterations in 0.09 seconds)
## Iteration 250: error is 66.774842 (50 iterations in 0.08 seconds)
## Iteration 300: error is 1.469454 (50 iterations in 0.08 seconds)
## Iteration 350: error is 1.288657 (50 iterations in 0.08 seconds)
## Iteration 400: error is 1.238455 (50 iterations in 0.08 seconds)
## Iteration 450: error is 1.214672 (50 iterations in 0.08 seconds)
## Iteration 500: error is 1.201567 (50 iterations in 0.08 seconds)
## Iteration 550: error is 1.192068 (50 iterations in 0.09 seconds)
## Iteration 600: error is 1.185352 (50 iterations in 0.08 seconds)
## Iteration 650: error is 1.180094 (50 iterations in 0.08 seconds)
## Iteration 700: error is 1.176568 (50 iterations in 0.08 seconds)
## Iteration 750: error is 1.173263 (50 iterations in 0.08 seconds)
## Iteration 800: error is 1.169136 (50 iterations in 0.08 seconds)
## Iteration 850: error is 1.167159 (50 iterations in 0.08 seconds)
## Iteration 900: error is 1.164652 (50 iterations in 0.08 seconds)
## Iteration 950: error is 1.163041 (50 iterations in 0.08 seconds)
## Iteration 1000: error is 1.160617 (50 iterations in 0.08 seconds)
## Fitting performed in 1.66 seconds.

## [1] "perplexity = 20, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.18 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 70.431353 (50 iterations in 0.13 seconds)
## Iteration 100: error is 64.164031 (50 iterations in 0.11 seconds)
## Iteration 150: error is 63.975747 (50 iterations in 0.11 seconds)
## Iteration 200: error is 63.973703 (50 iterations in 0.10 seconds)
## Iteration 250: error is 63.983099 (50 iterations in 0.10 seconds)
## Iteration 300: error is 1.323133 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.173139 (50 iterations in 0.09 seconds)
## Iteration 400: error is 1.132027 (50 iterations in 0.09 seconds)
## Iteration 450: error is 1.116489 (50 iterations in 0.09 seconds)
## Iteration 500: error is 1.106792 (50 iterations in 0.09 seconds)
## Iteration 550: error is 1.100205 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.094999 (50 iterations in 0.09 seconds)
## Iteration 650: error is 1.091468 (50 iterations in 0.09 seconds)
## Iteration 700: error is 1.089420 (50 iterations in 0.09 seconds)
## Iteration 750: error is 1.086815 (50 iterations in 0.09 seconds)
## Iteration 800: error is 1.084632 (50 iterations in 0.09 seconds)
## Iteration 850: error is 1.082568 (50 iterations in 0.09 seconds)
## Iteration 900: error is 1.080640 (50 iterations in 0.09 seconds)
## Iteration 950: error is 1.078654 (50 iterations in 0.09 seconds)
## Iteration 1000: error is 1.077224 (50 iterations in 0.09 seconds)
## Fitting performed in 1.96 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 40.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.142505)!
## Learning embedding...
## Iteration 50: error is 66.220600 (50 iterations in 0.14 seconds)
## Iteration 100: error is 61.971824 (50 iterations in 0.10 seconds)
## Iteration 150: error is 61.920258 (50 iterations in 0.09 seconds)
## Iteration 200: error is 61.920117 (50 iterations in 0.09 seconds)
## Iteration 250: error is 61.922101 (50 iterations in 0.09 seconds)
## Iteration 300: error is 1.214191 (50 iterations in 0.09 seconds)
## Iteration 350: error is 1.086799 (50 iterations in 0.09 seconds)
## Iteration 400: error is 1.050558 (50 iterations in 0.09 seconds)
## Iteration 450: error is 1.037082 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.026858 (50 iterations in 0.10 seconds)
## Iteration 550: error is 1.019752 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.014525 (50 iterations in 0.10 seconds)
## Iteration 650: error is 1.010900 (50 iterations in 0.10 seconds)
## Iteration 700: error is 1.007189 (50 iterations in 0.10 seconds)
## Iteration 750: error is 1.004845 (50 iterations in 0.10 seconds)
## Iteration 800: error is 1.002771 (50 iterations in 0.10 seconds)
## Iteration 850: error is 1.000559 (50 iterations in 0.11 seconds)
## Iteration 900: error is 0.999203 (50 iterations in 0.12 seconds)
## Iteration 950: error is 0.997763 (50 iterations in 0.10 seconds)
## Iteration 1000: error is 0.995762 (50 iterations in 0.10 seconds)
## Fitting performed in 2.03 seconds.

## [1] "perplexity = 40, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 50.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.29 seconds (sparsity = 0.177213)!
## Learning embedding...
## Iteration 50: error is 65.420653 (50 iterations in 0.13 seconds)
## Iteration 100: error is 60.430830 (50 iterations in 0.11 seconds)
## Iteration 150: error is 60.384249 (50 iterations in 0.10 seconds)
## Iteration 200: error is 60.379363 (50 iterations in 0.11 seconds)
## Iteration 250: error is 60.373496 (50 iterations in 0.10 seconds)
## Iteration 300: error is 1.112387 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.011949 (50 iterations in 0.10 seconds)
## Iteration 400: error is 0.977212 (50 iterations in 0.10 seconds)
## Iteration 450: error is 0.963085 (50 iterations in 0.10 seconds)
## Iteration 500: error is 0.955429 (50 iterations in 0.10 seconds)
## Iteration 550: error is 0.948371 (50 iterations in 0.10 seconds)
## Iteration 600: error is 0.943343 (50 iterations in 0.10 seconds)
## Iteration 650: error is 0.940266 (50 iterations in 0.10 seconds)
## Iteration 700: error is 0.936984 (50 iterations in 0.10 seconds)
## Iteration 750: error is 0.935321 (50 iterations in 0.10 seconds)
## Iteration 800: error is 0.933816 (50 iterations in 0.10 seconds)
## Iteration 850: error is 0.933101 (50 iterations in 0.10 seconds)
## Iteration 900: error is 0.931432 (50 iterations in 0.10 seconds)
## Iteration 950: error is 0.931017 (50 iterations in 0.10 seconds)
## Iteration 1000: error is 0.929069 (50 iterations in 0.10 seconds)
## Fitting performed in 2.04 seconds.

## [1] "perplexity = 50, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 60.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.33 seconds (sparsity = 0.211784)!
## Learning embedding...
## Iteration 50: error is 63.267779 (50 iterations in 0.14 seconds)
## Iteration 100: error is 59.228604 (50 iterations in 0.12 seconds)
## Iteration 150: error is 59.197523 (50 iterations in 0.11 seconds)
## Iteration 200: error is 59.193511 (50 iterations in 0.11 seconds)
## Iteration 250: error is 59.192444 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.026740 (50 iterations in 0.11 seconds)
## Iteration 350: error is 0.926086 (50 iterations in 0.11 seconds)
## Iteration 400: error is 0.900684 (50 iterations in 0.11 seconds)
## Iteration 450: error is 0.887785 (50 iterations in 0.12 seconds)
## Iteration 500: error is 0.881673 (50 iterations in 0.12 seconds)
## Iteration 550: error is 0.876040 (50 iterations in 0.12 seconds)
## Iteration 600: error is 0.873824 (50 iterations in 0.12 seconds)
## Iteration 650: error is 0.871162 (50 iterations in 0.12 seconds)
## Iteration 700: error is 0.868824 (50 iterations in 0.12 seconds)
## Iteration 750: error is 0.867584 (50 iterations in 0.12 seconds)
## Iteration 800: error is 0.866311 (50 iterations in 0.12 seconds)
## Iteration 850: error is 0.865137 (50 iterations in 0.12 seconds)
## Iteration 900: error is 0.865010 (50 iterations in 0.12 seconds)
## Iteration 950: error is 0.864102 (50 iterations in 0.12 seconds)
## Iteration 1000: error is 0.863659 (50 iterations in 0.12 seconds)
## Fitting performed in 2.34 seconds.

## [1] "perplexity = 60, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 70.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.37 seconds (sparsity = 0.245983)!
## Learning embedding...
## Iteration 50: error is 61.532988 (50 iterations in 0.15 seconds)
## Iteration 100: error is 58.312565 (50 iterations in 0.14 seconds)
## Iteration 150: error is 58.222273 (50 iterations in 0.12 seconds)
## Iteration 200: error is 58.221403 (50 iterations in 0.11 seconds)
## Iteration 250: error is 58.220339 (50 iterations in 0.11 seconds)
## Iteration 300: error is 0.965432 (50 iterations in 0.12 seconds)
## Iteration 350: error is 0.878655 (50 iterations in 0.12 seconds)
## Iteration 400: error is 0.856102 (50 iterations in 0.13 seconds)
## Iteration 450: error is 0.847363 (50 iterations in 0.13 seconds)
## Iteration 500: error is 0.842184 (50 iterations in 0.13 seconds)
## Iteration 550: error is 0.839625 (50 iterations in 0.14 seconds)
## Iteration 600: error is 0.838169 (50 iterations in 0.13 seconds)
## Iteration 650: error is 0.837779 (50 iterations in 0.13 seconds)
## Iteration 700: error is 0.837235 (50 iterations in 0.13 seconds)
## Iteration 750: error is 0.836940 (50 iterations in 0.14 seconds)
## Iteration 800: error is 0.836507 (50 iterations in 0.13 seconds)
## Iteration 850: error is 0.836160 (50 iterations in 0.13 seconds)
## Iteration 900: error is 0.835558 (50 iterations in 0.13 seconds)
## Iteration 950: error is 0.834764 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 0.834528 (50 iterations in 0.13 seconds)
## Fitting performed in 2.59 seconds.

## [1] "perplexity = 70, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 80.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.43 seconds (sparsity = 0.279712)!
## Learning embedding...
## Iteration 50: error is 59.975124 (50 iterations in 0.17 seconds)
## Iteration 100: error is 59.010512 (50 iterations in 0.18 seconds)
## Iteration 150: error is 57.461992 (50 iterations in 0.14 seconds)
## Iteration 200: error is 57.458618 (50 iterations in 0.13 seconds)
## Iteration 250: error is 57.459730 (50 iterations in 0.13 seconds)
## Iteration 300: error is 0.892298 (50 iterations in 0.13 seconds)
## Iteration 350: error is 0.814472 (50 iterations in 0.13 seconds)
## Iteration 400: error is 0.796324 (50 iterations in 0.13 seconds)
## Iteration 450: error is 0.789251 (50 iterations in 0.13 seconds)
## Iteration 500: error is 0.786215 (50 iterations in 0.14 seconds)
## Iteration 550: error is 0.784242 (50 iterations in 0.13 seconds)
## Iteration 600: error is 0.782853 (50 iterations in 0.14 seconds)
## Iteration 650: error is 0.781380 (50 iterations in 0.14 seconds)
## Iteration 700: error is 0.780686 (50 iterations in 0.13 seconds)
## Iteration 750: error is 0.779554 (50 iterations in 0.13 seconds)
## Iteration 800: error is 0.779396 (50 iterations in 0.13 seconds)
## Iteration 850: error is 0.779332 (50 iterations in 0.13 seconds)
## Iteration 900: error is 0.778723 (50 iterations in 0.13 seconds)
## Iteration 950: error is 0.778475 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 0.778400 (50 iterations in 0.13 seconds)
## Fitting performed in 2.74 seconds.

## [1] "perplexity = 80, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 90.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.47 seconds (sparsity = 0.312799)!
## Learning embedding...
## Iteration 50: error is 58.600529 (50 iterations in 0.16 seconds)
## Iteration 100: error is 58.060217 (50 iterations in 0.18 seconds)
## Iteration 150: error is 56.847098 (50 iterations in 0.16 seconds)
## Iteration 200: error is 56.842376 (50 iterations in 0.14 seconds)
## Iteration 250: error is 56.840787 (50 iterations in 0.14 seconds)
## Iteration 300: error is 0.861963 (50 iterations in 0.15 seconds)
## Iteration 350: error is 0.773164 (50 iterations in 0.13 seconds)
## Iteration 400: error is 0.755637 (50 iterations in 0.13 seconds)
## Iteration 450: error is 0.748900 (50 iterations in 0.13 seconds)
## Iteration 500: error is 0.745838 (50 iterations in 0.13 seconds)
## Iteration 550: error is 0.744250 (50 iterations in 0.13 seconds)
## Iteration 600: error is 0.742796 (50 iterations in 0.13 seconds)
## Iteration 650: error is 0.741754 (50 iterations in 0.13 seconds)
## Iteration 700: error is 0.741362 (50 iterations in 0.13 seconds)
## Iteration 750: error is 0.740777 (50 iterations in 0.13 seconds)
## Iteration 800: error is 0.740174 (50 iterations in 0.13 seconds)
## Iteration 850: error is 0.740155 (50 iterations in 0.13 seconds)
## Iteration 900: error is 0.739642 (50 iterations in 0.13 seconds)
## Iteration 950: error is 0.739336 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 0.738929 (50 iterations in 0.13 seconds)
## Fitting performed in 2.74 seconds.

## [1] "perplexity = 90, max_iter = 1000, learning rate = 250"
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.18 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 71.389156 (50 iterations in 0.10 seconds)
## Iteration 100: error is 67.965053 (50 iterations in 0.14 seconds)
## Iteration 150: error is 64.076443 (50 iterations in 0.11 seconds)
## Iteration 200: error is 63.974172 (50 iterations in 0.11 seconds)
## Iteration 250: error is 63.981044 (50 iterations in 0.10 seconds)
## Iteration 300: error is 1.618861 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.394249 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.290793 (50 iterations in 0.09 seconds)
## Iteration 450: error is 1.230490 (50 iterations in 0.09 seconds)
## Iteration 500: error is 1.191031 (50 iterations in 0.09 seconds)
## Iteration 550: error is 1.163311 (50 iterations in 0.09 seconds)
## Iteration 600: error is 1.145303 (50 iterations in 0.09 seconds)
## Iteration 650: error is 1.131780 (50 iterations in 0.09 seconds)
## Iteration 700: error is 1.122345 (50 iterations in 0.09 seconds)
## Iteration 750: error is 1.115422 (50 iterations in 0.09 seconds)
## Iteration 800: error is 1.109485 (50 iterations in 0.09 seconds)
## Iteration 850: error is 1.104676 (50 iterations in 0.09 seconds)
## Iteration 900: error is 1.100410 (50 iterations in 0.09 seconds)
## Iteration 950: error is 1.096778 (50 iterations in 0.09 seconds)
## Iteration 1000: error is 1.093423 (50 iterations in 0.09 seconds)
## Fitting performed in 1.97 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 20"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 71.231033 (50 iterations in 0.14 seconds)
## Iteration 100: error is 64.254163 (50 iterations in 0.12 seconds)
## Iteration 150: error is 63.973651 (50 iterations in 0.11 seconds)
## Iteration 200: error is 63.959468 (50 iterations in 0.11 seconds)
## Iteration 250: error is 63.968425 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.348560 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.174362 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.118101 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.091901 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.078569 (50 iterations in 0.10 seconds)
## Iteration 550: error is 1.072302 (50 iterations in 0.11 seconds)
## Iteration 600: error is 1.066842 (50 iterations in 0.11 seconds)
## Iteration 650: error is 1.061266 (50 iterations in 0.11 seconds)
## Iteration 700: error is 1.057299 (50 iterations in 0.11 seconds)
## Iteration 750: error is 1.054024 (50 iterations in 0.11 seconds)
## Iteration 800: error is 1.050986 (50 iterations in 0.11 seconds)
## Iteration 850: error is 1.048263 (50 iterations in 0.11 seconds)
## Iteration 900: error is 1.046249 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.044386 (50 iterations in 0.11 seconds)
## Iteration 1000: error is 1.042955 (50 iterations in 0.11 seconds)
## Fitting performed in 2.19 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 200"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 67.982953 (50 iterations in 0.15 seconds)
## Iteration 100: error is 64.122587 (50 iterations in 0.13 seconds)
## Iteration 150: error is 63.920289 (50 iterations in 0.12 seconds)
## Iteration 200: error is 63.912385 (50 iterations in 0.12 seconds)
## Iteration 250: error is 63.898330 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.311504 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.160548 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.112211 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.093172 (50 iterations in 0.11 seconds)
## Iteration 500: error is 1.082038 (50 iterations in 0.11 seconds)
## Iteration 550: error is 1.073687 (50 iterations in 0.11 seconds)
## Iteration 600: error is 1.068331 (50 iterations in 0.11 seconds)
## Iteration 650: error is 1.064417 (50 iterations in 0.11 seconds)
## Iteration 700: error is 1.061656 (50 iterations in 0.11 seconds)
## Iteration 750: error is 1.059428 (50 iterations in 0.13 seconds)
## Iteration 800: error is 1.057413 (50 iterations in 0.11 seconds)
## Iteration 850: error is 1.055091 (50 iterations in 0.11 seconds)
## Iteration 900: error is 1.053043 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.050542 (50 iterations in 0.11 seconds)
## Iteration 1000: error is 1.048299 (50 iterations in 0.11 seconds)
## Fitting performed in 2.28 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 300"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 73.284061 (50 iterations in 0.11 seconds)
## Iteration 100: error is 74.518153 (50 iterations in 0.13 seconds)
## Iteration 150: error is 74.685091 (50 iterations in 0.17 seconds)
## Iteration 200: error is 74.935133 (50 iterations in 0.18 seconds)
## Iteration 250: error is 75.047538 (50 iterations in 0.20 seconds)
## Iteration 300: error is 2.252234 (50 iterations in 0.11 seconds)
## Iteration 350: error is 1.519699 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.294582 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.238390 (50 iterations in 0.08 seconds)
## Iteration 500: error is 1.196392 (50 iterations in 0.09 seconds)
## Iteration 550: error is 1.191645 (50 iterations in 0.09 seconds)
## Iteration 600: error is 1.188605 (50 iterations in 0.09 seconds)
## Iteration 650: error is 1.181219 (50 iterations in 0.09 seconds)
## Iteration 700: error is 1.170167 (50 iterations in 0.09 seconds)
## Iteration 750: error is 1.162143 (50 iterations in 0.09 seconds)
## Iteration 800: error is 1.160640 (50 iterations in 0.09 seconds)
## Iteration 850: error is 1.158327 (50 iterations in 0.09 seconds)
## Iteration 900: error is 1.157036 (50 iterations in 0.09 seconds)
## Iteration 950: error is 1.155784 (50 iterations in 0.09 seconds)
## Iteration 1000: error is 1.154096 (50 iterations in 0.09 seconds)
## Fitting performed in 2.16 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 2000"
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

rm(list = ls())
#male vs female
library(stringr)
library(openxlsx)
  dirs <- as.data.frame(read.xlsx("F:/allGroups/dirs.xlsx"))
  num_of_pop<<-nrow(dirs)
  
  
  dir=as.data.frame(lapply(structure(.Data=1:1,.Names=1:1),function(x) numeric(num_of_pop)))
for (i in 1:num_of_pop){
  dir[i,1]<-dirs$groupNameDir[i]
}
#xlsxFile <<- choose.files(default = "", caption = "Select expData file")

groupsNames <<- as.character(basename(dirs$groupNameDir))

#chnage the dir values so it would be readable
dir$X1<-gsub("\\\\", "/", dir$X1)
for(i in 1:num_of_pop){
  dir[i,1]<-str_trim(dir[i,1], side = c("right"))
}




library("dplyr")
library("stringr")

Female<-data.frame()
Male<-data.frame()



#feature_names<-all_features %>%
# select(-ends_with('~'))
Female_index<-0
Male_index<-0

for(i in 1:num_of_pop){
  if(str_detect(basename(dir[i,1]), "Females")){
    Female_index<-Female_index+1
    setwd(dir[i,1])
    all_features<-read.csv("combined_per_fly.csv")
    #getting the colom names - getting the feature name e.g aggregation 
    feature_names<-all_features %>%
      select(starts_with('file'))
    
    #taking the first row of it and removing the col names
    names_data_frame<-as.data.frame(t(feature_names[1,]))
    rownames(names_data_frame)<-(NULL)
    colnames(names_data_frame)<-c("feature_name")
    #replace the feature names so they won't end with .mat ending
    names_data_frame$feature_name<- str_replace(names_data_frame$feature_name ,".mat", "")
    #converting them to list
    names_in_list<-as.list(names_data_frame$feature_name)
    all_features_names<-all_features$dir
    all_features_names<-as.data.frame(all_features_names)
    colnames(all_features_names)<-c("id")
    #taking the movie name and calling it id
    
    #taking only the values
    all_features_valus<-all_features %>%
      select(starts_with('valu'))
    #putting the name of the feature as colom name to the values
    colnames(all_features_valus)<-c(names_in_list)
    
    
    #test<-all_features_valus[,!grepl("*~",names(all_features_valus))]
    #connecting the names of the movies to the value and feature name
    
    #all_features_names<-cbind(all_features_names,all_features_valus[,!grepl("*~",names(all_features_valus))])
    all_features_names<-cbind(all_features_names,all_features_valus)
    all_features_names$id<-c("Female")
    if(Female_index==1){
      Female<-all_features_names
    }else{
      Female<-rbind(Female,all_features_names)
      
    }
    #putting factor on the label
    Female$id<-as.factor(Female$id)
  }
  
  
  
  if(str_detect(basename(dir[i,1]), "Males")){
    Male_index<-Male_index+1
    setwd(dir[i,1])
    all_features<-read.csv("combined_per_fly.csv")
    #getting the colom names - getting the feature name e.g aggregation 
    feature_names<-all_features %>%
      select(starts_with('file'))
    #taking the first row of it and removing the col names
    names_data_frame<-as.data.frame(t(feature_names[1,]))
    rownames(names_data_frame)<-(NULL)
    colnames(names_data_frame)<-c("feature_name")
    #replace the feature names so they won't end with .mat ending
    names_data_frame$feature_name<- str_replace(names_data_frame$feature_name ,".mat", "")
    #converting them to list
    names_in_list<-as.list(names_data_frame$feature_name)
    all_features_names<-all_features$dir
    all_features_names<-as.data.frame(all_features_names)
    colnames(all_features_names)<-c("id")
    #taking the movie name and calling it id
    
    #taking only the values
    all_features_valus<-all_features %>%
      select(starts_with('valu'))
    #putting the name of the feature as colom name to the values
    colnames(all_features_valus)<-c(names_in_list)
    
    #connecting the names of the movies to the value and feature name
    all_features_names<-cbind(all_features_names,all_features_valus)
    all_features_names$id<-c("Male")
    
    if(Male_index==1){
      Male<-all_features_names
    }else{
      Male<-rbind(Male,all_features_names)
      
    }
    #putting factor on the label
    Male$id<-as.factor(Male$id)
  }
  
  
}
all_feature_final<-rbind(Female,Male)

#this part was problematic for the random forest
colnames(all_feature_final) <- make.names(colnames(all_feature_final))


#check balance
all_feature_final %>% 
  count(id) %>% 
  mutate(prop = n/sum(n))
##       id   n      prop
## 1 Female 590 0.4957983
## 2   Male 600 0.5042017
actuall_data<-all_feature_final[,-1]

scaled_dat <- data.frame(lapply(actuall_data, function(x) scale(x, center = FALSE, scale = max(x, na.rm = TRUE)/1)))
scaled_dat<-cbind(all_feature_final$id,scaled_dat)
names(scaled_dat)[names(scaled_dat) == 'all_feature_final$id'] <- 'id'



library(readr)
library(Rtsne)
tag<-all_feature_final$id
colors = rainbow(length(unique(scaled_dat$id)))
names(colors) = unique(scaled_dat$id)

## Run the t-SNE algorithm and store the results into an object called tsne_results
tsne_results <- Rtsne(scaled_dat[,-1], perplexity=30, check_duplicates = FALSE)
#THE DEFULAT IS 1000 ITERS
plot(tsne_results$Y, col = "black", bg= scaled_dat$id, pch = 21, cex = 1.5)
text(tsne_results$Y, labels=scaled_dat$id, col=colors[scaled_dat$id])

##ALSO WITH SAMPLING

numTrain <-1190
set.seed(1)
rows <- sample(1:nrow(scaled_dat), numTrain)
train <- scaled_dat[rows,]

set.seed(1) # for reproducibility
tsne <- Rtsne(train[,-1], perplexity=30,check_duplicates = FALSE)


colors = rainbow(length(unique(train$id)))
names(colors) = unique(train$id)

plot(tsne$Y, t='n', main="tSNE", xlab="tSNE dimension 1", ylab="tSNE dimension 2", "cex.main"=2, "cex.lab"=0.5)
text(tsne$Y, labels=train$id, col=colors[train$id])

library(Rtsne)

tsne_plot <- function(perpl=30,iterations=1000,learning=250){
  set.seed(1) # for reproducibility
  tsne <- Rtsne(train[,-1], dims = 2, perplexity=perpl, verbose=TRUE, max_iter=iterations, eta=learning)
  plot(tsne$Y, t='n', main = print(paste0("perplexity = ",perpl, ", max_iter = ",iterations, ", learning rate = ",learning)), xlab="tSNE dimension 1", ylab="tSNE dimension 2", "cex.main"=1, "cex.lab"=1.5)
  text(tsne$Y, labels=train$id, col=colors[train$id],cex=0.5)
}

perplexity_values <- c(20,30,40,50,60,70,80,90)
sapply(perplexity_values,function(i){tsne_plot(perpl=i)})
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 20.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.15 seconds (sparsity = 0.072217)!
## Learning embedding...
## Iteration 50: error is 74.609042 (50 iterations in 0.12 seconds)
## Iteration 100: error is 67.234096 (50 iterations in 0.09 seconds)
## Iteration 150: error is 66.872623 (50 iterations in 0.09 seconds)
## Iteration 200: error is 66.797404 (50 iterations in 0.09 seconds)
## Iteration 250: error is 66.774842 (50 iterations in 0.09 seconds)
## Iteration 300: error is 1.469454 (50 iterations in 0.08 seconds)
## Iteration 350: error is 1.288657 (50 iterations in 0.08 seconds)
## Iteration 400: error is 1.238455 (50 iterations in 0.08 seconds)
## Iteration 450: error is 1.214672 (50 iterations in 0.08 seconds)
## Iteration 500: error is 1.201567 (50 iterations in 0.08 seconds)
## Iteration 550: error is 1.192068 (50 iterations in 0.08 seconds)
## Iteration 600: error is 1.185352 (50 iterations in 0.08 seconds)
## Iteration 650: error is 1.180094 (50 iterations in 0.08 seconds)
## Iteration 700: error is 1.176568 (50 iterations in 0.08 seconds)
## Iteration 750: error is 1.173263 (50 iterations in 0.08 seconds)
## Iteration 800: error is 1.169136 (50 iterations in 0.08 seconds)
## Iteration 850: error is 1.167159 (50 iterations in 0.08 seconds)
## Iteration 900: error is 1.164652 (50 iterations in 0.08 seconds)
## Iteration 950: error is 1.163041 (50 iterations in 0.08 seconds)
## Iteration 1000: error is 1.160617 (50 iterations in 0.08 seconds)
## Fitting performed in 1.69 seconds.

## [1] "perplexity = 20, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 70.431353 (50 iterations in 0.14 seconds)
## Iteration 100: error is 64.164031 (50 iterations in 0.11 seconds)
## Iteration 150: error is 63.975747 (50 iterations in 0.11 seconds)
## Iteration 200: error is 63.973703 (50 iterations in 0.11 seconds)
## Iteration 250: error is 63.983099 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.323133 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.173139 (50 iterations in 0.09 seconds)
## Iteration 400: error is 1.132027 (50 iterations in 0.09 seconds)
## Iteration 450: error is 1.116489 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.106792 (50 iterations in 0.09 seconds)
## Iteration 550: error is 1.100205 (50 iterations in 0.09 seconds)
## Iteration 600: error is 1.094999 (50 iterations in 0.10 seconds)
## Iteration 650: error is 1.091468 (50 iterations in 0.09 seconds)
## Iteration 700: error is 1.089420 (50 iterations in 0.10 seconds)
## Iteration 750: error is 1.086815 (50 iterations in 0.10 seconds)
## Iteration 800: error is 1.084632 (50 iterations in 0.10 seconds)
## Iteration 850: error is 1.082568 (50 iterations in 0.10 seconds)
## Iteration 900: error is 1.080640 (50 iterations in 0.10 seconds)
## Iteration 950: error is 1.078654 (50 iterations in 0.10 seconds)
## Iteration 1000: error is 1.077224 (50 iterations in 0.09 seconds)
## Fitting performed in 2.02 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 40.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.142505)!
## Learning embedding...
## Iteration 50: error is 66.220600 (50 iterations in 0.14 seconds)
## Iteration 100: error is 61.971824 (50 iterations in 0.10 seconds)
## Iteration 150: error is 61.920258 (50 iterations in 0.10 seconds)
## Iteration 200: error is 61.920117 (50 iterations in 0.10 seconds)
## Iteration 250: error is 61.922101 (50 iterations in 0.10 seconds)
## Iteration 300: error is 1.214191 (50 iterations in 0.09 seconds)
## Iteration 350: error is 1.086799 (50 iterations in 0.09 seconds)
## Iteration 400: error is 1.050558 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.037082 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.026858 (50 iterations in 0.10 seconds)
## Iteration 550: error is 1.019752 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.014525 (50 iterations in 0.10 seconds)
## Iteration 650: error is 1.010900 (50 iterations in 0.10 seconds)
## Iteration 700: error is 1.007189 (50 iterations in 0.10 seconds)
## Iteration 750: error is 1.004845 (50 iterations in 0.10 seconds)
## Iteration 800: error is 1.002771 (50 iterations in 0.10 seconds)
## Iteration 850: error is 1.000559 (50 iterations in 0.10 seconds)
## Iteration 900: error is 0.999203 (50 iterations in 0.10 seconds)
## Iteration 950: error is 0.997763 (50 iterations in 0.11 seconds)
## Iteration 1000: error is 0.995762 (50 iterations in 0.10 seconds)
## Fitting performed in 2.07 seconds.

## [1] "perplexity = 40, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 50.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.28 seconds (sparsity = 0.177213)!
## Learning embedding...
## Iteration 50: error is 65.420653 (50 iterations in 0.13 seconds)
## Iteration 100: error is 60.430830 (50 iterations in 0.11 seconds)
## Iteration 150: error is 60.384249 (50 iterations in 0.10 seconds)
## Iteration 200: error is 60.379363 (50 iterations in 0.10 seconds)
## Iteration 250: error is 60.373496 (50 iterations in 0.10 seconds)
## Iteration 300: error is 1.112387 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.011949 (50 iterations in 0.10 seconds)
## Iteration 400: error is 0.977212 (50 iterations in 0.10 seconds)
## Iteration 450: error is 0.963085 (50 iterations in 0.10 seconds)
## Iteration 500: error is 0.955429 (50 iterations in 0.10 seconds)
## Iteration 550: error is 0.948371 (50 iterations in 0.10 seconds)
## Iteration 600: error is 0.943343 (50 iterations in 0.10 seconds)
## Iteration 650: error is 0.940266 (50 iterations in 0.10 seconds)
## Iteration 700: error is 0.936984 (50 iterations in 0.09 seconds)
## Iteration 750: error is 0.935321 (50 iterations in 0.10 seconds)
## Iteration 800: error is 0.933816 (50 iterations in 0.10 seconds)
## Iteration 850: error is 0.933101 (50 iterations in 0.09 seconds)
## Iteration 900: error is 0.931432 (50 iterations in 0.10 seconds)
## Iteration 950: error is 0.931017 (50 iterations in 0.10 seconds)
## Iteration 1000: error is 0.929069 (50 iterations in 0.10 seconds)
## Fitting performed in 2.00 seconds.

## [1] "perplexity = 50, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 60.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.32 seconds (sparsity = 0.211784)!
## Learning embedding...
## Iteration 50: error is 63.267779 (50 iterations in 0.14 seconds)
## Iteration 100: error is 59.228604 (50 iterations in 0.12 seconds)
## Iteration 150: error is 59.197523 (50 iterations in 0.11 seconds)
## Iteration 200: error is 59.193511 (50 iterations in 0.11 seconds)
## Iteration 250: error is 59.192444 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.026740 (50 iterations in 0.10 seconds)
## Iteration 350: error is 0.926086 (50 iterations in 0.11 seconds)
## Iteration 400: error is 0.900684 (50 iterations in 0.11 seconds)
## Iteration 450: error is 0.887785 (50 iterations in 0.12 seconds)
## Iteration 500: error is 0.881673 (50 iterations in 0.12 seconds)
## Iteration 550: error is 0.876040 (50 iterations in 0.12 seconds)
## Iteration 600: error is 0.873824 (50 iterations in 0.12 seconds)
## Iteration 650: error is 0.871162 (50 iterations in 0.12 seconds)
## Iteration 700: error is 0.868824 (50 iterations in 0.12 seconds)
## Iteration 750: error is 0.867584 (50 iterations in 0.12 seconds)
## Iteration 800: error is 0.866311 (50 iterations in 0.12 seconds)
## Iteration 850: error is 0.865137 (50 iterations in 0.12 seconds)
## Iteration 900: error is 0.865010 (50 iterations in 0.12 seconds)
## Iteration 950: error is 0.864102 (50 iterations in 0.12 seconds)
## Iteration 1000: error is 0.863659 (50 iterations in 0.12 seconds)
## Fitting performed in 2.33 seconds.

## [1] "perplexity = 60, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 70.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.37 seconds (sparsity = 0.245983)!
## Learning embedding...
## Iteration 50: error is 61.532988 (50 iterations in 0.15 seconds)
## Iteration 100: error is 58.312565 (50 iterations in 0.14 seconds)
## Iteration 150: error is 58.222273 (50 iterations in 0.11 seconds)
## Iteration 200: error is 58.221403 (50 iterations in 0.11 seconds)
## Iteration 250: error is 58.220339 (50 iterations in 0.11 seconds)
## Iteration 300: error is 0.965432 (50 iterations in 0.12 seconds)
## Iteration 350: error is 0.878655 (50 iterations in 0.12 seconds)
## Iteration 400: error is 0.856102 (50 iterations in 0.13 seconds)
## Iteration 450: error is 0.847363 (50 iterations in 0.13 seconds)
## Iteration 500: error is 0.842184 (50 iterations in 0.13 seconds)
## Iteration 550: error is 0.839625 (50 iterations in 0.13 seconds)
## Iteration 600: error is 0.838169 (50 iterations in 0.13 seconds)
## Iteration 650: error is 0.837779 (50 iterations in 0.13 seconds)
## Iteration 700: error is 0.837235 (50 iterations in 0.13 seconds)
## Iteration 750: error is 0.836940 (50 iterations in 0.13 seconds)
## Iteration 800: error is 0.836507 (50 iterations in 0.13 seconds)
## Iteration 850: error is 0.836160 (50 iterations in 0.13 seconds)
## Iteration 900: error is 0.835558 (50 iterations in 0.13 seconds)
## Iteration 950: error is 0.834764 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 0.834528 (50 iterations in 0.13 seconds)
## Fitting performed in 2.56 seconds.

## [1] "perplexity = 70, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 80.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.42 seconds (sparsity = 0.279712)!
## Learning embedding...
## Iteration 50: error is 59.975124 (50 iterations in 0.17 seconds)
## Iteration 100: error is 59.010512 (50 iterations in 0.17 seconds)
## Iteration 150: error is 57.461992 (50 iterations in 0.14 seconds)
## Iteration 200: error is 57.458618 (50 iterations in 0.13 seconds)
## Iteration 250: error is 57.459730 (50 iterations in 0.13 seconds)
## Iteration 300: error is 0.892298 (50 iterations in 0.13 seconds)
## Iteration 350: error is 0.814472 (50 iterations in 0.13 seconds)
## Iteration 400: error is 0.796324 (50 iterations in 0.13 seconds)
## Iteration 450: error is 0.789251 (50 iterations in 0.13 seconds)
## Iteration 500: error is 0.786215 (50 iterations in 0.13 seconds)
## Iteration 550: error is 0.784242 (50 iterations in 0.13 seconds)
## Iteration 600: error is 0.782853 (50 iterations in 0.13 seconds)
## Iteration 650: error is 0.781380 (50 iterations in 0.13 seconds)
## Iteration 700: error is 0.780686 (50 iterations in 0.14 seconds)
## Iteration 750: error is 0.779554 (50 iterations in 0.13 seconds)
## Iteration 800: error is 0.779396 (50 iterations in 0.13 seconds)
## Iteration 850: error is 0.779332 (50 iterations in 0.13 seconds)
## Iteration 900: error is 0.778723 (50 iterations in 0.13 seconds)
## Iteration 950: error is 0.778475 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 0.778400 (50 iterations in 0.13 seconds)
## Fitting performed in 2.70 seconds.

## [1] "perplexity = 80, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 90.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.48 seconds (sparsity = 0.312799)!
## Learning embedding...
## Iteration 50: error is 58.600529 (50 iterations in 0.16 seconds)
## Iteration 100: error is 58.060217 (50 iterations in 0.18 seconds)
## Iteration 150: error is 56.847098 (50 iterations in 0.16 seconds)
## Iteration 200: error is 56.842376 (50 iterations in 0.14 seconds)
## Iteration 250: error is 56.840787 (50 iterations in 0.14 seconds)
## Iteration 300: error is 0.861963 (50 iterations in 0.14 seconds)
## Iteration 350: error is 0.773164 (50 iterations in 0.13 seconds)
## Iteration 400: error is 0.755637 (50 iterations in 0.13 seconds)
## Iteration 450: error is 0.748900 (50 iterations in 0.13 seconds)
## Iteration 500: error is 0.745838 (50 iterations in 0.13 seconds)
## Iteration 550: error is 0.744250 (50 iterations in 0.13 seconds)
## Iteration 600: error is 0.742796 (50 iterations in 0.13 seconds)
## Iteration 650: error is 0.741754 (50 iterations in 0.13 seconds)
## Iteration 700: error is 0.741362 (50 iterations in 0.13 seconds)
## Iteration 750: error is 0.740777 (50 iterations in 0.13 seconds)
## Iteration 800: error is 0.740174 (50 iterations in 0.13 seconds)
## Iteration 850: error is 0.740155 (50 iterations in 0.13 seconds)
## Iteration 900: error is 0.739642 (50 iterations in 0.13 seconds)
## Iteration 950: error is 0.739336 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 0.738929 (50 iterations in 0.13 seconds)
## Fitting performed in 2.71 seconds.

## [1] "perplexity = 90, max_iter = 1000, learning rate = 250"
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
learning_values <- c(20,200,300,2000)
sapply(learning_values,function(i){tsne_plot(learning=i)})
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 71.389156 (50 iterations in 0.10 seconds)
## Iteration 100: error is 67.965053 (50 iterations in 0.14 seconds)
## Iteration 150: error is 64.076443 (50 iterations in 0.11 seconds)
## Iteration 200: error is 63.974172 (50 iterations in 0.11 seconds)
## Iteration 250: error is 63.981044 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.618861 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.394249 (50 iterations in 0.09 seconds)
## Iteration 400: error is 1.290793 (50 iterations in 0.09 seconds)
## Iteration 450: error is 1.230490 (50 iterations in 0.09 seconds)
## Iteration 500: error is 1.191031 (50 iterations in 0.09 seconds)
## Iteration 550: error is 1.163311 (50 iterations in 0.09 seconds)
## Iteration 600: error is 1.145303 (50 iterations in 0.10 seconds)
## Iteration 650: error is 1.131780 (50 iterations in 0.09 seconds)
## Iteration 700: error is 1.122345 (50 iterations in 0.09 seconds)
## Iteration 750: error is 1.115422 (50 iterations in 0.09 seconds)
## Iteration 800: error is 1.109485 (50 iterations in 0.10 seconds)
## Iteration 850: error is 1.104676 (50 iterations in 0.09 seconds)
## Iteration 900: error is 1.100410 (50 iterations in 0.09 seconds)
## Iteration 950: error is 1.096778 (50 iterations in 0.09 seconds)
## Iteration 1000: error is 1.093423 (50 iterations in 0.10 seconds)
## Fitting performed in 2.00 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 20"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 71.231033 (50 iterations in 0.14 seconds)
## Iteration 100: error is 64.254163 (50 iterations in 0.12 seconds)
## Iteration 150: error is 63.973651 (50 iterations in 0.11 seconds)
## Iteration 200: error is 63.959468 (50 iterations in 0.11 seconds)
## Iteration 250: error is 63.968425 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.348560 (50 iterations in 0.11 seconds)
## Iteration 350: error is 1.174362 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.118101 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.091901 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.078569 (50 iterations in 0.10 seconds)
## Iteration 550: error is 1.072302 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.066842 (50 iterations in 0.11 seconds)
## Iteration 650: error is 1.061266 (50 iterations in 0.10 seconds)
## Iteration 700: error is 1.057299 (50 iterations in 0.11 seconds)
## Iteration 750: error is 1.054024 (50 iterations in 0.11 seconds)
## Iteration 800: error is 1.050986 (50 iterations in 0.11 seconds)
## Iteration 850: error is 1.048263 (50 iterations in 0.11 seconds)
## Iteration 900: error is 1.046249 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.044386 (50 iterations in 0.11 seconds)
## Iteration 1000: error is 1.042955 (50 iterations in 0.11 seconds)
## Fitting performed in 2.20 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 200"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 67.982953 (50 iterations in 0.16 seconds)
## Iteration 100: error is 64.122587 (50 iterations in 0.14 seconds)
## Iteration 150: error is 63.920289 (50 iterations in 0.12 seconds)
## Iteration 200: error is 63.912385 (50 iterations in 0.12 seconds)
## Iteration 250: error is 63.898330 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.311504 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.160548 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.112211 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.093172 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.082038 (50 iterations in 0.11 seconds)
## Iteration 550: error is 1.073687 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.068331 (50 iterations in 0.11 seconds)
## Iteration 650: error is 1.064417 (50 iterations in 0.11 seconds)
## Iteration 700: error is 1.061656 (50 iterations in 0.11 seconds)
## Iteration 750: error is 1.059428 (50 iterations in 0.11 seconds)
## Iteration 800: error is 1.057413 (50 iterations in 0.11 seconds)
## Iteration 850: error is 1.055091 (50 iterations in 0.11 seconds)
## Iteration 900: error is 1.053043 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.050542 (50 iterations in 0.11 seconds)
## Iteration 1000: error is 1.048299 (50 iterations in 0.10 seconds)
## Fitting performed in 2.24 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 300"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.19 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 73.284061 (50 iterations in 0.11 seconds)
## Iteration 100: error is 74.518153 (50 iterations in 0.13 seconds)
## Iteration 150: error is 74.685091 (50 iterations in 0.18 seconds)
## Iteration 200: error is 74.935133 (50 iterations in 0.17 seconds)
## Iteration 250: error is 75.047538 (50 iterations in 0.21 seconds)
## Iteration 300: error is 2.252234 (50 iterations in 0.14 seconds)
## Iteration 350: error is 1.519699 (50 iterations in 0.11 seconds)
## Iteration 400: error is 1.294582 (50 iterations in 0.11 seconds)
## Iteration 450: error is 1.238390 (50 iterations in 0.09 seconds)
## Iteration 500: error is 1.196392 (50 iterations in 0.09 seconds)
## Iteration 550: error is 1.191645 (50 iterations in 0.09 seconds)
## Iteration 600: error is 1.188605 (50 iterations in 0.09 seconds)
## Iteration 650: error is 1.181219 (50 iterations in 0.09 seconds)
## Iteration 700: error is 1.170167 (50 iterations in 0.09 seconds)
## Iteration 750: error is 1.162143 (50 iterations in 0.09 seconds)
## Iteration 800: error is 1.160640 (50 iterations in 0.09 seconds)
## Iteration 850: error is 1.158327 (50 iterations in 0.09 seconds)
## Iteration 900: error is 1.157036 (50 iterations in 0.09 seconds)
## Iteration 950: error is 1.155784 (50 iterations in 0.09 seconds)
## Iteration 1000: error is 1.154096 (50 iterations in 0.09 seconds)
## Fitting performed in 2.25 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 2000"
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
par(mfrow=c(3,3))
optPerp <- round(sqrt(104),0)
for(i in c( 200, 300, 500,1000,2000,3000,4000,5000,6000))
{
    tsne <- Rtsne(train[,-1],
              perplexity=30, max_iter=i)
    plot(tsne$Y, col="blue", xlab="tSNE1", ylab="tSNE2", cex=0.5)
    mtext(paste0("max_iter = ", i))
}

library(readr)
library(Rtsne)
tag<-all_feature_final$id
colors = rainbow(length(unique(scaled_dat$id)))
names(colors) = unique(scaled_dat$id)

## Run the t-SNE algorithm and store the results into an object called tsne_results
tsne_results <- Rtsne(scaled_dat[,-1], perplexity=30, check_duplicates = FALSE)
#THE DEFULAT IS 1000 ITERS
plot(tsne_results$Y, col = "black", bg= scaled_dat$id, pch = 21, cex = 1.5)
text(tsne_results$Y, labels=scaled_dat$id, col=colors[scaled_dat$id])

##ALSO WITH SAMPLING

numTrain <-1190
set.seed(1)
rows <- sample(1:nrow(scaled_dat), numTrain)
train <- scaled_dat[rows,]

set.seed(1) # for reproducibility
tsne <- Rtsne(train[,-1], perplexity=30,check_duplicates = FALSE)


colors = rainbow(length(unique(train$id)))
names(colors) = unique(train$id)

plot(tsne$Y, t='n', main="tSNE", xlab="tSNE dimension 1", ylab="tSNE dimension 2", "cex.main"=2, "cex.lab"=0.5)
text(tsne$Y, labels=train$id, col=colors[train$id])

library(Rtsne)

tsne_plot <- function(perpl=30,iterations=1000,learning=250){
  set.seed(1) # for reproducibility
  tsne <- Rtsne(train[,-1], dims = 2, perplexity=perpl, verbose=TRUE, max_iter=iterations, eta=learning)
  plot(tsne$Y, t='n', main = print(paste0("perplexity = ",perpl, ", max_iter = ",iterations, ", learning rate = ",learning)), xlab="tSNE dimension 1", ylab="tSNE dimension 2", "cex.main"=1, "cex.lab"=1.5)
  text(tsne$Y, labels=train$id, col=colors[train$id],cex=0.5)
}

perplexity_values <- c(20,30,40,50,60,70,80,90)
sapply(perplexity_values,function(i){tsne_plot(perpl=i)})
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 20.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.18 seconds (sparsity = 0.072217)!
## Learning embedding...
## Iteration 50: error is 74.609042 (50 iterations in 0.14 seconds)
## Iteration 100: error is 67.234096 (50 iterations in 0.11 seconds)
## Iteration 150: error is 66.872623 (50 iterations in 0.10 seconds)
## Iteration 200: error is 66.797404 (50 iterations in 0.11 seconds)
## Iteration 250: error is 66.774842 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.469454 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.288657 (50 iterations in 0.10 seconds)
## Iteration 400: error is 1.238455 (50 iterations in 0.10 seconds)
## Iteration 450: error is 1.214672 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.201567 (50 iterations in 0.10 seconds)
## Iteration 550: error is 1.192068 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.185352 (50 iterations in 0.10 seconds)
## Iteration 650: error is 1.180094 (50 iterations in 0.10 seconds)
## Iteration 700: error is 1.176568 (50 iterations in 0.10 seconds)
## Iteration 750: error is 1.173263 (50 iterations in 0.10 seconds)
## Iteration 800: error is 1.169136 (50 iterations in 0.10 seconds)
## Iteration 850: error is 1.167159 (50 iterations in 0.10 seconds)
## Iteration 900: error is 1.164652 (50 iterations in 0.10 seconds)
## Iteration 950: error is 1.163041 (50 iterations in 0.10 seconds)
## Iteration 1000: error is 1.160617 (50 iterations in 0.10 seconds)
## Fitting performed in 2.05 seconds.

## [1] "perplexity = 20, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 70.431353 (50 iterations in 0.22 seconds)
## Iteration 100: error is 64.164031 (50 iterations in 0.17 seconds)
## Iteration 150: error is 63.975747 (50 iterations in 0.15 seconds)
## Iteration 200: error is 63.973703 (50 iterations in 0.14 seconds)
## Iteration 250: error is 63.983099 (50 iterations in 0.14 seconds)
## Iteration 300: error is 1.323133 (50 iterations in 0.12 seconds)
## Iteration 350: error is 1.173139 (50 iterations in 0.11 seconds)
## Iteration 400: error is 1.132027 (50 iterations in 0.11 seconds)
## Iteration 450: error is 1.116489 (50 iterations in 0.12 seconds)
## Iteration 500: error is 1.106792 (50 iterations in 0.13 seconds)
## Iteration 550: error is 1.100205 (50 iterations in 0.13 seconds)
## Iteration 600: error is 1.094999 (50 iterations in 0.14 seconds)
## Iteration 650: error is 1.091468 (50 iterations in 0.12 seconds)
## Iteration 700: error is 1.089420 (50 iterations in 0.12 seconds)
## Iteration 750: error is 1.086815 (50 iterations in 0.11 seconds)
## Iteration 800: error is 1.084632 (50 iterations in 0.11 seconds)
## Iteration 850: error is 1.082568 (50 iterations in 0.11 seconds)
## Iteration 900: error is 1.080640 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.078654 (50 iterations in 0.11 seconds)
## Iteration 1000: error is 1.077224 (50 iterations in 0.11 seconds)
## Fitting performed in 2.59 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 40.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.27 seconds (sparsity = 0.142505)!
## Learning embedding...
## Iteration 50: error is 66.220600 (50 iterations in 0.16 seconds)
## Iteration 100: error is 61.971824 (50 iterations in 0.11 seconds)
## Iteration 150: error is 61.920258 (50 iterations in 0.11 seconds)
## Iteration 200: error is 61.920117 (50 iterations in 0.11 seconds)
## Iteration 250: error is 61.922101 (50 iterations in 0.11 seconds)
## Iteration 300: error is 1.214191 (50 iterations in 0.10 seconds)
## Iteration 350: error is 1.086799 (50 iterations in 0.11 seconds)
## Iteration 400: error is 1.050558 (50 iterations in 0.11 seconds)
## Iteration 450: error is 1.037082 (50 iterations in 0.11 seconds)
## Iteration 500: error is 1.026858 (50 iterations in 0.11 seconds)
## Iteration 550: error is 1.019752 (50 iterations in 0.12 seconds)
## Iteration 600: error is 1.014525 (50 iterations in 0.12 seconds)
## Iteration 650: error is 1.010900 (50 iterations in 0.12 seconds)
## Iteration 700: error is 1.007189 (50 iterations in 0.12 seconds)
## Iteration 750: error is 1.004845 (50 iterations in 0.12 seconds)
## Iteration 800: error is 1.002771 (50 iterations in 0.12 seconds)
## Iteration 850: error is 1.000559 (50 iterations in 0.12 seconds)
## Iteration 900: error is 0.999203 (50 iterations in 0.12 seconds)
## Iteration 950: error is 0.997763 (50 iterations in 0.12 seconds)
## Iteration 1000: error is 0.995762 (50 iterations in 0.12 seconds)
## Fitting performed in 2.32 seconds.

## [1] "perplexity = 40, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 50.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.32 seconds (sparsity = 0.177213)!
## Learning embedding...
## Iteration 50: error is 65.420653 (50 iterations in 0.15 seconds)
## Iteration 100: error is 60.430830 (50 iterations in 0.12 seconds)
## Iteration 150: error is 60.384249 (50 iterations in 0.12 seconds)
## Iteration 200: error is 60.379363 (50 iterations in 0.11 seconds)
## Iteration 250: error is 60.373496 (50 iterations in 0.12 seconds)
## Iteration 300: error is 1.112387 (50 iterations in 0.12 seconds)
## Iteration 350: error is 1.011949 (50 iterations in 0.11 seconds)
## Iteration 400: error is 0.977212 (50 iterations in 0.12 seconds)
## Iteration 450: error is 0.963085 (50 iterations in 0.12 seconds)
## Iteration 500: error is 0.955429 (50 iterations in 0.12 seconds)
## Iteration 550: error is 0.948371 (50 iterations in 0.12 seconds)
## Iteration 600: error is 0.943343 (50 iterations in 0.12 seconds)
## Iteration 650: error is 0.940266 (50 iterations in 0.12 seconds)
## Iteration 700: error is 0.936984 (50 iterations in 0.12 seconds)
## Iteration 750: error is 0.935321 (50 iterations in 0.12 seconds)
## Iteration 800: error is 0.933816 (50 iterations in 0.12 seconds)
## Iteration 850: error is 0.933101 (50 iterations in 0.12 seconds)
## Iteration 900: error is 0.931432 (50 iterations in 0.12 seconds)
## Iteration 950: error is 0.931017 (50 iterations in 0.12 seconds)
## Iteration 1000: error is 0.929069 (50 iterations in 0.12 seconds)
## Fitting performed in 2.37 seconds.

## [1] "perplexity = 50, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 60.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.40 seconds (sparsity = 0.211784)!
## Learning embedding...
## Iteration 50: error is 63.267779 (50 iterations in 0.17 seconds)
## Iteration 100: error is 59.228604 (50 iterations in 0.14 seconds)
## Iteration 150: error is 59.197523 (50 iterations in 0.14 seconds)
## Iteration 200: error is 59.193511 (50 iterations in 0.13 seconds)
## Iteration 250: error is 59.192444 (50 iterations in 0.14 seconds)
## Iteration 300: error is 1.026740 (50 iterations in 0.14 seconds)
## Iteration 350: error is 0.926086 (50 iterations in 0.13 seconds)
## Iteration 400: error is 0.900684 (50 iterations in 0.14 seconds)
## Iteration 450: error is 0.887785 (50 iterations in 0.14 seconds)
## Iteration 500: error is 0.881673 (50 iterations in 0.14 seconds)
## Iteration 550: error is 0.876040 (50 iterations in 0.14 seconds)
## Iteration 600: error is 0.873824 (50 iterations in 0.14 seconds)
## Iteration 650: error is 0.871162 (50 iterations in 0.14 seconds)
## Iteration 700: error is 0.868824 (50 iterations in 0.14 seconds)
## Iteration 750: error is 0.867584 (50 iterations in 0.14 seconds)
## Iteration 800: error is 0.866311 (50 iterations in 0.14 seconds)
## Iteration 850: error is 0.865137 (50 iterations in 0.14 seconds)
## Iteration 900: error is 0.865010 (50 iterations in 0.14 seconds)
## Iteration 950: error is 0.864102 (50 iterations in 0.14 seconds)
## Iteration 1000: error is 0.863659 (50 iterations in 0.14 seconds)
## Fitting performed in 2.80 seconds.

## [1] "perplexity = 60, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 70.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.42 seconds (sparsity = 0.245983)!
## Learning embedding...
## Iteration 50: error is 61.532988 (50 iterations in 0.16 seconds)
## Iteration 100: error is 58.312565 (50 iterations in 0.15 seconds)
## Iteration 150: error is 58.222273 (50 iterations in 0.12 seconds)
## Iteration 200: error is 58.221403 (50 iterations in 0.12 seconds)
## Iteration 250: error is 58.220339 (50 iterations in 0.12 seconds)
## Iteration 300: error is 0.965432 (50 iterations in 0.14 seconds)
## Iteration 350: error is 0.878655 (50 iterations in 0.14 seconds)
## Iteration 400: error is 0.856102 (50 iterations in 0.14 seconds)
## Iteration 450: error is 0.847363 (50 iterations in 0.14 seconds)
## Iteration 500: error is 0.842184 (50 iterations in 0.15 seconds)
## Iteration 550: error is 0.839625 (50 iterations in 0.15 seconds)
## Iteration 600: error is 0.838169 (50 iterations in 0.15 seconds)
## Iteration 650: error is 0.837779 (50 iterations in 0.15 seconds)
## Iteration 700: error is 0.837235 (50 iterations in 0.15 seconds)
## Iteration 750: error is 0.836940 (50 iterations in 0.15 seconds)
## Iteration 800: error is 0.836507 (50 iterations in 0.15 seconds)
## Iteration 850: error is 0.836160 (50 iterations in 0.15 seconds)
## Iteration 900: error is 0.835558 (50 iterations in 0.15 seconds)
## Iteration 950: error is 0.834764 (50 iterations in 0.15 seconds)
## Iteration 1000: error is 0.834528 (50 iterations in 0.15 seconds)
## Fitting performed in 2.88 seconds.

## [1] "perplexity = 70, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 80.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.49 seconds (sparsity = 0.279712)!
## Learning embedding...
## Iteration 50: error is 59.975124 (50 iterations in 0.19 seconds)
## Iteration 100: error is 59.010512 (50 iterations in 0.19 seconds)
## Iteration 150: error is 57.461992 (50 iterations in 0.16 seconds)
## Iteration 200: error is 57.458618 (50 iterations in 0.15 seconds)
## Iteration 250: error is 57.459730 (50 iterations in 0.14 seconds)
## Iteration 300: error is 0.892298 (50 iterations in 0.15 seconds)
## Iteration 350: error is 0.814472 (50 iterations in 0.14 seconds)
## Iteration 400: error is 0.796324 (50 iterations in 0.18 seconds)
## Iteration 450: error is 0.789251 (50 iterations in 0.17 seconds)
## Iteration 500: error is 0.786215 (50 iterations in 0.20 seconds)
## Iteration 550: error is 0.784242 (50 iterations in 0.20 seconds)
## Iteration 600: error is 0.782853 (50 iterations in 0.18 seconds)
## Iteration 650: error is 0.781380 (50 iterations in 0.17 seconds)
## Iteration 700: error is 0.780686 (50 iterations in 0.17 seconds)
## Iteration 750: error is 0.779554 (50 iterations in 0.17 seconds)
## Iteration 800: error is 0.779396 (50 iterations in 0.16 seconds)
## Iteration 850: error is 0.779332 (50 iterations in 0.16 seconds)
## Iteration 900: error is 0.778723 (50 iterations in 0.16 seconds)
## Iteration 950: error is 0.778475 (50 iterations in 0.16 seconds)
## Iteration 1000: error is 0.778400 (50 iterations in 0.16 seconds)
## Fitting performed in 3.36 seconds.

## [1] "perplexity = 80, max_iter = 1000, learning rate = 250"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 90.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.56 seconds (sparsity = 0.312799)!
## Learning embedding...
## Iteration 50: error is 58.600529 (50 iterations in 0.19 seconds)
## Iteration 100: error is 58.060217 (50 iterations in 0.21 seconds)
## Iteration 150: error is 56.847098 (50 iterations in 0.19 seconds)
## Iteration 200: error is 56.842376 (50 iterations in 0.17 seconds)
## Iteration 250: error is 56.840787 (50 iterations in 0.17 seconds)
## Iteration 300: error is 0.861963 (50 iterations in 0.17 seconds)
## Iteration 350: error is 0.773164 (50 iterations in 0.16 seconds)
## Iteration 400: error is 0.755637 (50 iterations in 0.15 seconds)
## Iteration 450: error is 0.748900 (50 iterations in 0.15 seconds)
## Iteration 500: error is 0.745838 (50 iterations in 0.15 seconds)
## Iteration 550: error is 0.744250 (50 iterations in 0.16 seconds)
## Iteration 600: error is 0.742796 (50 iterations in 0.15 seconds)
## Iteration 650: error is 0.741754 (50 iterations in 0.15 seconds)
## Iteration 700: error is 0.741362 (50 iterations in 0.15 seconds)
## Iteration 750: error is 0.740777 (50 iterations in 0.15 seconds)
## Iteration 800: error is 0.740174 (50 iterations in 0.15 seconds)
## Iteration 850: error is 0.740155 (50 iterations in 0.16 seconds)
## Iteration 900: error is 0.739642 (50 iterations in 0.15 seconds)
## Iteration 950: error is 0.739336 (50 iterations in 0.15 seconds)
## Iteration 1000: error is 0.738929 (50 iterations in 0.16 seconds)
## Fitting performed in 3.26 seconds.

## [1] "perplexity = 90, max_iter = 1000, learning rate = 250"
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
## 
## [[5]]
## NULL
## 
## [[6]]
## NULL
## 
## [[7]]
## NULL
## 
## [[8]]
## NULL
learning_values <- c(20,200,300,2000)
sapply(learning_values,function(i){tsne_plot(learning=i)})
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 71.389156 (50 iterations in 0.12 seconds)
## Iteration 100: error is 67.965053 (50 iterations in 0.17 seconds)
## Iteration 150: error is 64.076443 (50 iterations in 0.13 seconds)
## Iteration 200: error is 63.974172 (50 iterations in 0.13 seconds)
## Iteration 250: error is 63.981044 (50 iterations in 0.13 seconds)
## Iteration 300: error is 1.618861 (50 iterations in 0.13 seconds)
## Iteration 350: error is 1.394249 (50 iterations in 0.12 seconds)
## Iteration 400: error is 1.290793 (50 iterations in 0.11 seconds)
## Iteration 450: error is 1.230490 (50 iterations in 0.11 seconds)
## Iteration 500: error is 1.191031 (50 iterations in 0.12 seconds)
## Iteration 550: error is 1.163311 (50 iterations in 0.12 seconds)
## Iteration 600: error is 1.145303 (50 iterations in 0.12 seconds)
## Iteration 650: error is 1.131780 (50 iterations in 0.12 seconds)
## Iteration 700: error is 1.122345 (50 iterations in 0.12 seconds)
## Iteration 750: error is 1.115422 (50 iterations in 0.12 seconds)
## Iteration 800: error is 1.109485 (50 iterations in 0.12 seconds)
## Iteration 850: error is 1.104676 (50 iterations in 0.12 seconds)
## Iteration 900: error is 1.100410 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.096778 (50 iterations in 0.12 seconds)
## Iteration 1000: error is 1.093423 (50 iterations in 0.12 seconds)
## Fitting performed in 2.42 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 20"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 71.231033 (50 iterations in 0.17 seconds)
## Iteration 100: error is 64.254163 (50 iterations in 0.15 seconds)
## Iteration 150: error is 63.973651 (50 iterations in 0.14 seconds)
## Iteration 200: error is 63.959468 (50 iterations in 0.13 seconds)
## Iteration 250: error is 63.968425 (50 iterations in 0.14 seconds)
## Iteration 300: error is 1.348560 (50 iterations in 0.13 seconds)
## Iteration 350: error is 1.174362 (50 iterations in 0.12 seconds)
## Iteration 400: error is 1.118101 (50 iterations in 0.13 seconds)
## Iteration 450: error is 1.091901 (50 iterations in 0.13 seconds)
## Iteration 500: error is 1.078569 (50 iterations in 0.13 seconds)
## Iteration 550: error is 1.072302 (50 iterations in 0.13 seconds)
## Iteration 600: error is 1.066842 (50 iterations in 0.13 seconds)
## Iteration 650: error is 1.061266 (50 iterations in 0.13 seconds)
## Iteration 700: error is 1.057299 (50 iterations in 0.13 seconds)
## Iteration 750: error is 1.054024 (50 iterations in 0.13 seconds)
## Iteration 800: error is 1.050986 (50 iterations in 0.14 seconds)
## Iteration 850: error is 1.048263 (50 iterations in 0.14 seconds)
## Iteration 900: error is 1.046249 (50 iterations in 0.13 seconds)
## Iteration 950: error is 1.044386 (50 iterations in 0.14 seconds)
## Iteration 1000: error is 1.042955 (50 iterations in 0.13 seconds)
## Fitting performed in 2.68 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 200"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 67.982953 (50 iterations in 0.18 seconds)
## Iteration 100: error is 64.122587 (50 iterations in 0.16 seconds)
## Iteration 150: error is 63.920289 (50 iterations in 0.14 seconds)
## Iteration 200: error is 63.912385 (50 iterations in 0.14 seconds)
## Iteration 250: error is 63.898330 (50 iterations in 0.14 seconds)
## Iteration 300: error is 1.311504 (50 iterations in 0.13 seconds)
## Iteration 350: error is 1.160548 (50 iterations in 0.12 seconds)
## Iteration 400: error is 1.112211 (50 iterations in 0.12 seconds)
## Iteration 450: error is 1.093172 (50 iterations in 0.13 seconds)
## Iteration 500: error is 1.082038 (50 iterations in 0.13 seconds)
## Iteration 550: error is 1.073687 (50 iterations in 0.13 seconds)
## Iteration 600: error is 1.068331 (50 iterations in 0.13 seconds)
## Iteration 650: error is 1.064417 (50 iterations in 0.13 seconds)
## Iteration 700: error is 1.061656 (50 iterations in 0.13 seconds)
## Iteration 750: error is 1.059428 (50 iterations in 0.13 seconds)
## Iteration 800: error is 1.057413 (50 iterations in 0.13 seconds)
## Iteration 850: error is 1.055091 (50 iterations in 0.13 seconds)
## Iteration 900: error is 1.053043 (50 iterations in 0.13 seconds)
## Iteration 950: error is 1.050542 (50 iterations in 0.13 seconds)
## Iteration 1000: error is 1.048299 (50 iterations in 0.14 seconds)
## Fitting performed in 2.71 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 300"
## Performing PCA
## Read the 1190 x 50 data matrix successfully!
## OpenMP is working. 1 threads.
## Using no_dims = 2, perplexity = 30.000000, and theta = 0.500000
## Computing input similarities...
## Building tree...
## Done in 0.23 seconds (sparsity = 0.107440)!
## Learning embedding...
## Iteration 50: error is 73.284061 (50 iterations in 0.13 seconds)
## Iteration 100: error is 74.518153 (50 iterations in 0.16 seconds)
## Iteration 150: error is 74.685091 (50 iterations in 0.21 seconds)
## Iteration 200: error is 74.935133 (50 iterations in 0.21 seconds)
## Iteration 250: error is 75.047538 (50 iterations in 0.24 seconds)
## Iteration 300: error is 2.252234 (50 iterations in 0.13 seconds)
## Iteration 350: error is 1.519699 (50 iterations in 0.12 seconds)
## Iteration 400: error is 1.294582 (50 iterations in 0.12 seconds)
## Iteration 450: error is 1.238390 (50 iterations in 0.10 seconds)
## Iteration 500: error is 1.196392 (50 iterations in 0.10 seconds)
## Iteration 550: error is 1.191645 (50 iterations in 0.10 seconds)
## Iteration 600: error is 1.188605 (50 iterations in 0.10 seconds)
## Iteration 650: error is 1.181219 (50 iterations in 0.11 seconds)
## Iteration 700: error is 1.170167 (50 iterations in 0.11 seconds)
## Iteration 750: error is 1.162143 (50 iterations in 0.10 seconds)
## Iteration 800: error is 1.160640 (50 iterations in 0.10 seconds)
## Iteration 850: error is 1.158327 (50 iterations in 0.10 seconds)
## Iteration 900: error is 1.157036 (50 iterations in 0.11 seconds)
## Iteration 950: error is 1.155784 (50 iterations in 0.10 seconds)
## Iteration 1000: error is 1.154096 (50 iterations in 0.10 seconds)
## Fitting performed in 2.57 seconds.

## [1] "perplexity = 30, max_iter = 1000, learning rate = 2000"
## [[1]]
## NULL
## 
## [[2]]
## NULL
## 
## [[3]]
## NULL
## 
## [[4]]
## NULL
par(mfrow=c(3,3))
optPerp <- round(sqrt(104),0)
for(i in c( 200, 300, 500,1000,2000,3000,4000,5000,6000))
{
    tsne <- Rtsne(train[,-1],
              perplexity=30, max_iter=i)
    plot(tsne$Y, col="blue", xlab="tSNE1", ylab="tSNE2", cex=0.5)
    mtext(paste0("max_iter = ", i))
}